<!DOCTYPE html>
<html lang="zh-cn">
<#include "../include/resource-head.ftl"/>
<link rel="stylesheet" href="/themes/plugins/fileinput/css/fileinput.min.css">
<body>
<#include "../include/common-header.ftl"/>
<div class="container col-center-block">
    <h3>订单信息</h3>
    <div class="order-detail">
        <h4>店铺：<a href="#">999</a></h4>
        <div class="order-detail-goods">
            <div class="col-sm-3">
                <div class="pull-left">
                    <a href="/goods/detail/${goodsModel.id}">
                        <img src="/data/${goodsModel.icon!}" height="60px" width="60px">
                        <span>${goodsModel.name!}</span>
                    </a>
                </div>
            </div>
            <div class="col-sm-3"><span class="col-sm-4">单价:</span><span
                    class="text-red col-sm-6">￥${goodsModel.price?string('#0.00')}</span></div>
            <div class="col-sm-3">
                <span class="col-sm-4">数量:</span>
                <div class="input-group col-sm-6" style="margin-top: 16px">
                    <span class="input-group-addon" id="minus">-</span>
                    <input type="text" class="form-control" value="${num!1}" id="num" readonly form="form" name="count">
                    <span class="input-group-addon" id="add">+</span>
                </div>
            </div>
            <div class="col-sm-3"><span class="col-sm-4">小计:</span><span class="text-red col-sm-6">￥<span
                    id="total">${(goodsModel.price * num!1)?string('#0.00')}</span></span></div>
        </div>
        <h4>告诉卖家</h4>
        <div class="order-detail-info">
            <form class="form-horizontal" role="form" method="post" action="/order/lunch" enctype="multipart/form-data"
                  id="form" name="form">
                <input type="hidden" name="goodsId" value="${goodsModel.id}">
                <div class="col-sm-12">
                    <div class="col-sm-6">
                    <#if goodsModel.type == 1>
                        <p>${goodsModel.introduction!}</p>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">定制图片</label>
                            <div class="col-sm-6">
                                <input type="file" id="icon" name="icon">
                            </div>
                        </div>
                    </#if>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">备注</label>
                            <div class="col-sm-6">
                                <textarea class="form-control" name="remark"></textarea>
                            </div>
                        </div>
                        <div class="form-group pull-right">
                            <div class="col-sm-6">
                                <input class="btn btn-warning" type="submit" value="提交订单" style="padding: 6px 20px">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">收货人</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" placeholder="收货人" name="receiveuser">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">收货地址</label>
                            <div class="col-sm-6">
                                <textarea class="form-control" name="receiveaddress"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>
<#include "../include/common-foot.ftl"/>
</body>
<#include "../include/resource-script.ftl"/>
<script src="/themes/plugins/fileinput/js/fileinput.min.js"></script>
<script src="/themes/plugins/fileinput/js/fileinput_locale_zh.js"></script>
<script>
    var img = "/data/${goodsModel.filePath!}";
        $("#icon").fileinput({
            showRemove: true,//显示移除按钮
            showUpload: false,
            language: 'zh',//语言
            uploadAsync: true,
            allowedPreviewTypes: ['image'],
            //allowedFileExtensions : [ 'png', 'jpg' ],//后缀
            showPreview: true,//预览
            elErrorContainer: "#errorBlock",
            browseClass: "btn btn-primary ", //按钮样式
            removeIcon: '<i></i>',
            browseIcon: '<i class=""></i>',
            previewFileIcon: '<i class=""></i>',
            <#if goodsModel.filePath??>
            initialPreview: [
                '<img src='+img+' width="200px" class="file-preview-image"/>'],
            </#if>
            removeClass: "btn btn-info "
        });


    $("#num").onlyNum();
    $("#minus").click(function () {
        var num = $("#num").val();

        if (parseInt(num) > parseInt(1)) {
            $("#num").val(parseInt(num) - 1);
            $("#total").text(parseInt($("#num").val()) * parseInt(${goodsModel.price?string('#0.00')}));
        }
    });
    $("#add").click(function () {
        var num = $("#num").val();
        $("#num").val(parseInt(num) + 1);
        $("#total").text(parseInt($("#num").val()) * parseInt(${goodsModel.price?string('#0.00')}));
    });
</script>
</html>